package com.ymatou.iapi.godmch.testcase;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.listcodeBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.godmch.service.listcodeCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.sqlwapper.godmch.agent_typeWapper;
import com.ymttest.database.sqlwapper.godmch.invite_codeWapper;
/**
*邀请码列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_listcode{
	private static listcodeBean bean;
	private static listcodeCall call;
	private agent_typeWapper agentTypeWapper=new agent_typeWapper();
	private invite_codeWapper codeWapper=new invite_codeWapper();
	 private invite_codeWapper inviteCodeWapper=new invite_codeWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("邀请码列表");
	}

	@Before
	public void caseUp() {
		bean=new listcodeBean();
		call=new listcodeCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_001() {
		Logger.start(true,"邀请码列表,验商户id正确,永久,pageIndex=1,pageSize=10,返回商户id的永久邀请码");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			
			checkVerify(1,userId_channl);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_002() {
		Logger.start(true,"邀请码列表,验商户id正确,非永久,pageIndex=1,pageSize=10,返回商户id的非永久邀请码");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, false);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			
			checkVerify(1,userId_channl);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_003() {
		Logger.start(true,"邀请码列表,验商户id正确,非永久并且已经过期,pageIndex=1,pageSize=10,返回商户id的非永久邀请码");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, false);
			CreateCodeCall codeCall=GodmchManageCallService.createCodeCall(codeBean);
			
//			invite_code model2=inviteCodeWapper.selectByPrimaryKey(Integer.parseInt(codeCall.getCode()));
			invite_code model2=inviteCodeWapper.selectByCode(codeCall.getCode());
			Calendar Cal=java.util.Calendar.getInstance();   
	        Cal.setTime(model2.getCreateTime());   
	        Cal.add(java.util.Calendar.DAY_OF_YEAR,-2);  //目前配置一天后过期 
	        inviteCodeWapper.updateExpireByCode(codeCall.getCode(), Cal.getTime());
	        
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(0, call.getTotal(), "验证总个数Total");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_004() {
		Logger.start(true,"邀请码列表,验商户id正确,每页记录数pageSize大于邀请码总数-pageIndex=1,pageSize=999999,返回第一页显示邀请码总数");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(999999);
			call.setData(bean);
			call.callService();			
			
			checkVerify(1,userId_channl);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_005() {
		Logger.start(true,"邀请码列表,验商户id正确,页码为0-pageIndex=0,pageSize=5,返回错误");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(0);
			bean.setPageSize(5);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatus1(), "验证status");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_006() {
		Logger.start(true,"邀请码列表,验商户id正确,每页记录数为0-pageIndex=1,pageSize=0,返回错误");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(0);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("4001", call.getStatus1(), "验证status");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_007() {
		Logger.start(true,"邀请码列表,验商户id正确,总页码数大于邀请码显示的总页码数-pageIndex=999999,pageSize=5,返回空");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(999999);
			bean.setPageSize(5);
			call.setData(bean);
			call.callService();				
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证msg");		
			Logger.verifyEquals(1, call.getTotal(), "验证Total=1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_008() {
		Logger.start(true,"邀请码列表,验商户id正确,邀请码显示的总页码数>2页-pageIndex=1,pageSize=1,返回第一页");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			
			ArrayList createCodeList=new ArrayList();
			for( int i=0;i<2;i++){
				CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, false);
				CreateCodeCall codeCall=GodmchManageCallService.createCodeCall(codeBean);
				Thread.sleep(1000);
				if(!createCodeList.contains(codeCall.getCode()))
					createCodeList.add(codeCall.getCode());
			}
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(1);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(2, call.getTotal(), "验证总个数Total");
			JsonArray jsonArray=call.getCodesList();
			//验证邀请码

//			invite_code code=codeWapper.selectByPrimaryKey(Integer.parseInt(createCodeList.get(1).toString()));
			invite_code code=inviteCodeWapper.selectByCode(createCodeList.get(1).toString());
			Logger.verifyEquals(1, call.getCodesList().size(), "验证CodesList个数");
			Logger.comment("验证邀请码");

			Logger.verifyEquals(code.getInviteCode(), new JSONObject(jsonArray.get(0).toString()).getString("code"), "验证数据库invite_code中的InviteCode字段与返回code是否一致");

			Logger.verifyEquals(code.getExpireTime()==null?1:2, new JSONObject(jsonArray.get(0).toString()).getInt("codeType"), "验证数据库invite_code 中的CodeRole字段与返回codeType是否一致");
			Logger.verifyEquals(code.getRoleType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库invite_code 中的agentType字段与返回RoleType是否一致");
			
			//验证代理类型
			Logger.comment("验证代理类型");
		    agent_type type=agentTypeWapper.selectByPrimaryKey(code.getRoleType());
		    Logger.verifyEquals(type.getAgentType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		    Logger.verifyEquals(type.getTypeTitle(), new JSONObject(jsonArray.get(0).toString()).getString("agentTypeTitle"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_009() {
		Logger.start(true,"邀请码列表,验商户id正确,邀请码显示的总页码数>2页-pageIndex=2,pageSize=1,返回第二页");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			
			ArrayList createCodeList=new ArrayList();
			for( int i=0;i<5;i++){
				CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, false);
				CreateCodeCall codeCall=GodmchManageCallService.createCodeCall(codeBean);
				Thread.sleep(1000);
				if(!createCodeList.contains(codeCall.getCode()))
					createCodeList.add(codeCall.getCode());
			}
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(2);
			bean.setPageSize(1);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(5, call.getTotal(), "验证总个数Total");
			JsonArray jsonArray=call.getCodesList();
			//验证邀请码
			HashMap<String,Object> map1=new HashMap();
			map1.put("mchId", userId_channl);
			map1.put("mchId", userId_channl);
//			invite_code code=codeWapper.selectByPrimaryKey(Integer.parseInt(createCodeList.get(3).toString()));
			invite_code code=inviteCodeWapper.selectByCode(createCodeList.get(3).toString());
			Logger.verifyEquals(1, call.getCodesList().size(), "验证CodesList个数");
			Logger.comment("验证邀请码");
			Logger.verifyEquals(code.getInviteCode(), new JSONObject(jsonArray.get(0).toString()).getString("code"), "验证数据库invite_code中的InviteCode字段与返回code是否一致");
			Logger.verifyEquals(code.getExpireTime()==null?1:2, new JSONObject(jsonArray.get(0).toString()).getInt("codeType"), "验证数据库invite_code 中的CodeRole字段与返回codeType是否一致");
			Logger.verifyEquals(code.getRoleType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库invite_code 中的agentType字段与返回RoleType是否一致");
			
			//验证代理类型
			Logger.comment("验证代理类型");
		    agent_type type=agentTypeWapper.selectByPrimaryKey(code.getRoleType());
		    Logger.verifyEquals(type.getAgentType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		    Logger.verifyEquals(type.getTypeTitle(), new JSONObject(jsonArray.get(0).toString()).getString("agentTypeTitle"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_010() {
		Logger.start(true,"邀请码列表,验商户id正确,邀请码显示的总页码数>2页,查看最后一页，-pageIndex=5,pageSize=1,返回最后一页");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			
			ArrayList createCodeList=new ArrayList();
			for( int i=0;i<5;i++){
				CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, false);
				CreateCodeCall codeCall=GodmchManageCallService.createCodeCall(codeBean);
				Thread.sleep(500);
				if(!createCodeList.contains(codeCall.getCode()))
					createCodeList.add(codeCall.getCode());
			}
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(5);
			bean.setPageSize(1);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(5, call.getTotal(), "验证总个数Total");
			JsonArray jsonArray=call.getCodesList();
			//验证邀请码
			HashMap<String,Object> map1=new HashMap();
			map1.put("mchId", userId_channl);
			map1.put("mchId", userId_channl);
//			invite_code code=codeWapper.selectByPrimaryKey(Integer.parseInt(createCodeList.get(0).toString()));
			invite_code code=inviteCodeWapper.selectByCode(createCodeList.get(0).toString());
			Logger.verifyEquals(1, call.getCodesList().size(), "验证CodesList个数");
			Logger.comment("验证邀请码");
			Logger.verifyEquals(code.getInviteCode(), new JSONObject(jsonArray.get(0).toString()).getString("code"), "验证数据库invite_code中的InviteCode字段与返回code是否一致");
			Logger.verifyEquals(code.getExpireTime()==null?1:2, new JSONObject(jsonArray.get(0).toString()).getInt("codeType"), "验证数据库invite_code 中的CodeRole字段与返回codeType是否一致");
			Logger.verifyEquals(code.getRoleType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库invite_code 中的agentType字段与返回RoleType是否一致");
			
			//验证代理类型
			Logger.comment("验证代理类型");
		    agent_type type=agentTypeWapper.selectByPrimaryKey(code.getRoleType());
		    Logger.verifyEquals(type.getAgentType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		    Logger.verifyEquals(type.getTypeTitle(), new JSONObject(jsonArray.get(0).toString()).getString("agentTypeTitle"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_011() {
		Logger.start(true,"邀请码列表,验邀请码 代理模式是1 - 自主选货（分销代理）,传入agentModel=2，返回空");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(10);
			bean.setAgentMode(2);//代理商邀请码代理模式 1 - 自主选货（分销代理） 2 - 自动继承（分销小店）
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(0, call.getTotal(), "验证总个数Total");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_listcode_012() {
		//目前验邀请码中含 不可能含有代理模式是2
		Logger.start(true,"邀请码列表,验邀请码中含 代理模式是2 - 自动继承（分销小店）,传入agentModel=1，返回代理模式是1的数据");
		try {
			UserCreateBean usercreateBean1=DGUserCallService.initUsercreateBean();
			int userId_channl=DGUserCallService.UserCreateCall(usercreateBean1);
			Logger.comment("创建渠道商户");
			createmchBean createmchBean=GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchBean);
			
			createagentBean createagentBean=GodmchManageCallService.InitCreateAgentTypeBean(userId_channl);
			createagentBean.setAgentMode(2);
			createagentCall createagentCall=GodmchManageCallService.CreateAgentTypeCall(createagentBean);
			
			Logger.comment("创建渠道商户邀请码");
			CreateCodeBean codeBean=GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl, true);
			
//			agent_typeWapper agentTypewapper = new agent_typeWapper();
//			Map<String, Object> map = new HashMap();
//			map.put("mchId", userId_channl);
//			List<agent_type> agenttypeList = agentTypewapper.selectby(map);
//			codeBean.setRoleType(agenttypeList.get(1).getAgentType());
			
			GodmchManageCallService.createCodeCall(codeBean);
			
			bean.setMchId(userId_channl);
			bean.setCodeRole(1);
			bean.setPageIndex(1);
			bean.setPageSize(10);
			bean.setAgentMode(1);//代理商邀请码代理模式 1 - 自主选货（分销代理） 2 - 自动继承（分销小店）
			call.setData(bean);
			call.callService();			
			
			JsonArray jsonArray=call.getCodesList();
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			
			//验证邀请码
			HashMap<String,Object> map1=new HashMap();
			map1.put("mchId", userId_channl);
			List<invite_code> codeList=codeWapper.selectby(map1);
			
			invite_code code=codeList.get(0);
			Logger.verifyEquals(1, call.getCodesList().size(), "验证CodesList个数");
			Logger.comment("验证邀请码");
			Logger.verifyEquals(code.getInviteCode(), new JSONObject(jsonArray.get(0).toString()).getString("code"), "验证数据库invite_code中的InviteCode字段与返回code是否一致");

			Logger.verifyEquals(code.getExpireTime()==null?1:2, new JSONObject(jsonArray.get(0).toString()).getInt("codeType"), "验证数据库invite_code 中的CodeRole字段与返回codeType是否一致");
			Logger.verifyEquals(code.getRoleType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库invite_code 中的agentType字段与返回RoleType是否一致");
			
			//验证代理类型
			Logger.comment("验证代理类型");
		    agent_type type=agentTypeWapper.selectByPrimaryKey(code.getRoleType());
		    Logger.verifyEquals(type.getAgentType(), new JSONObject(jsonArray.get(0).toString()).getInt("agentType"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		    Logger.verifyEquals(type.getTypeTitle(), new JSONObject(jsonArray.get(0).toString()).getString("agentTypeTitle"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	/**
	 * 验证
	 * @param total 邀请码总个数
	 * @param userId_channl 商户id
	 * @throws JSONException
	 * @throws InterruptedException
	 */
	private void checkVerify(int total,int userId_channl) throws JSONException, InterruptedException
	{
		Logger.verifyEquals("200", call.getStatus1(), "验证status");
		Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
		Logger.verifyEquals(total, call.getTotal(), "验证总个数Total");
		JsonArray jsonArray=call.getCodesList();
		//验证邀请码
		HashMap<String,Object> map1=new HashMap();
		map1.put("mchId", userId_channl);
		List<invite_code> codeList=codeWapper.selectby(map1);
		for(int i=0;i<codeList.size();i++)
		{
			Logger.verifyEquals(codeList.size(), call.getCodesList().size(), "验证CodesList个数");
			Logger.comment("验证邀请码");
			invite_code code=codeList.get(i);
			Logger.verifyEquals(code.getInviteCode(), new JSONObject(jsonArray.get(i).toString()).getString("code"), "验证数据库invite_code中的InviteCode字段与返回code是否一致");

			Logger.verifyEquals(code.getExpireTime()==null?1:2, new JSONObject(jsonArray.get(i).toString()).getInt("codeType"), "验证数据库invite_code 中的CodeRole字段与返回codeType是否一致");
			Logger.verifyEquals(code.getRoleType(), new JSONObject(jsonArray.get(i).toString()).getInt("agentType"), "验证数据库invite_code 中的agentType字段与返回RoleType是否一致");
			
			//验证代理类型
			Logger.comment("验证代理类型");
		    agent_type type=agentTypeWapper.selectByPrimaryKey(code.getRoleType());
		    Logger.verifyEquals(type.getAgentType(), new JSONObject(jsonArray.get(i).toString()).getInt("agentType"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		    Logger.verifyEquals(type.getTypeTitle(), new JSONObject(jsonArray.get(i).toString()).getString("agentTypeTitle"), "验证数据库agent_type 中的CodeRole字段与返回codeType是否一致");
		}
	}
}